1 module features.vcruntime140; 2 public import feature; 3 import commons; 4 5 6 Feature VCRuntime140Feature; 7 version(Posix) 8 { 9 void initialize(){} 10 void start(){} 11 } 12 else version(Windows): 13 14 enum VCRuntimeVer = "14.0"; 15 16 import commons; 17 import std.windows.registry; 18 static import std.file; 19 20 bool hasVCRuntime140(ref Terminal t, TargetVersion ver, out ExistenceStatus status) 21 { 22 string arch = "X64"; 23 version(Win32) arch = "X32"; 24 Key currKey = windowsGetKeyWithPath("SOFTWARE", "WOW6432Node", "Microsoft", "VisualStudio", ver.toString, "VC", "Runtimes", arch); 25 return currKey.getValue("Installed").value_DWORD == 1; 26 } 27 28 private string getVCDownloadLink() 29 { 30 version(Win64) return "https://aka.ms/vs/17/release/vc_redist.x64.exe"; 31 else version(Win32) return "https://aka.ms/vs/17/release/vc_redist.x86.exe"; 32 else version(AArch64) return "https://aka.ms/vs/17/release/vc_redist.arm64.exe"; 33 } 34 35 private bool installVCRuntime140(ref Terminal t, ref RealTimeConsoleInput input, TargetVersion ver, Download[] content) 36 { 37 auto ret = t.wait(spawnShell(content[0].getOutputPath(ver)~" /install /quiet /norestart")) == 0; 38 if(ret) 39 t.writelnSuccess("Successfully installed Microsoft Visual C++ Redistributable."); 40 else 41 t.writelnError("Could not install Microsoft Visual C++ Redistributable."); 42 return ret; 43 } 44 45 void initialize() 46 { 47 VCRuntime140Feature = Feature( 48 "VCRuntime140", 49 "VCRuntime is a binary necessary for running D compiler.", 50 ExistenceChecker(null, null, toDelegate(&hasVCRuntime140)), 51 Installation( 52 [ 53 Download( 54 DownloadURL( 55 windows: getVCDownloadLink 56 ), 57 outputPath: "$CWD/buildtools/vcredist.exe" 58 ) 59 ], toDelegate(&installVCRuntime140) 60 ), 61 null, 62 VersionRange.parse(VCRuntimeVer), 63 ); 64 } 65 void start(){}